@extends('backstage.layout.master')
@section('title', '编辑权限')
@section('style')

@stop
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>
        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="backstage/home">主页</a>
            </li>
            <li>
                <a href="backstage/permissions/list">权限列表</a>
            </li>
            <li class="active">
                编辑权限
            </li>
        </ul><!-- .breadcrumb -->
    </div>
    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        编辑权限
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" role="form" action="backstage/permissions/update" method="post"
                              enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                            <input type="hidden" name="id" value="{{$permission->id}}">

                            <div class="form-group {{$errors->first('display_name')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right"> 权限名称 </label>

                                <div class="col-sm-4">
                                    <input type="text" name="display_name" value="{{$permission->display_name}}"
                                           placeholder="权限名称"
                                           class="width-100">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('display_name')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('name')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right"> 权限 </label>

                                <div class="col-sm-4">
                                    <input type="text" name="name" value="{{$permission->name}}" placeholder="权限"
                                           class="width-100">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('name')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('parent_id')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right"> 上级权限 </label>

                                <div class="col-sm-4">
                                    <select name="parent_id">
                                        <option value="0">顶级权限</option>
                                        @foreach($permissions as $vo)
                                            @if($vo['id']==$permission->parent_id)
                                                <option value="{{$vo['id']}}" selected>{{$vo['display_name']}}</option>
                                            @else
                                                <option value="{{$vo['id']}}">{{$vo['display_name']}}</option>
                                            @endif
                                            @foreach($vo['child'] as $v)
                                                @if($v['id']==$permission->parent_id)
                                                    <option value="{{$v['id']}}" selected>
                                                        ┗━{{$v['display_name']}}</option>
                                                @else
                                                    <option value="{{$v['id']}}">┗━{{$v['display_name']}}</option>
                                                @endif
                                            @endforeach
                                        @endforeach
                                    </select>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('parent_id')}}</div>
                                </div>
                            </div>
                            <div class="form-group {{$errors->first('description')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right"> 描述</label>

                                <div class="col-sm-4">
                                    <textarea class="form-control" name="description"
                                              placeholder="描述">{{$permission->description}}</textarea>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('description')}}</div>
                                </div>
                            </div>
                            <div class="form-group {{$errors->first('is_menu')!=""?'has-error':''}}">
                                <label class="col-md-4 control-label">是否是菜单:</label>

                                <div class="col-md-4">
                                    <input type="radio" name="is_menu" value="1" id="yes"
                                           @if($permission->is_menu == 1) checked @endif> <label for="yes">是</label>
                                    &nbsp;&nbsp;&nbsp;<input type="radio" name="is_menu" value="0" id="no"
                                                             @if($permission->is_menu == 0) checked @endif> <label
                                            for="no">否</label>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('is_menu')}}</div>
                                </div>
                            </div>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-5 col-md-7">
                                    <button class="btn btn-info" type="submit">
                                        <i class="icon-ok bigger-110"></i>
                                        保存
                                    </button>
                                    &nbsp; &nbsp; &nbsp;
                                    <button class="btn" type="reset">
                                        <i class="icon-undo bigger-110"></i>
                                        重置
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div><!-- /.col -->
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
@stop